﻿
@{
    ViewBag.Title = "限时购";
    Layout = "~/Views/Shared/_MallLayout.cshtml";
    var banner = ViewBag.banner;
    var img_url = ViewBag.img_url;
}
@model activity_dto
@section style{
    <link href="~/Content/css/tokenmall/css/special.css" rel="stylesheet" />
    <link href="~/Scripts/mescroll/mescroll.min.css" rel="stylesheet" />
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -webkit-tap-highlight-color: transparent;
        }
        .mescroll {
            position: fixed;
            top: 0;
            bottom: 0;
            height: auto;
            background: #050238;
        }
        /*.mescroll-upwarp{
            padding: 0 ;
            min-height: 5px;
        }*/
        .page-morebuy .return_top{
            margin-bottom:0;
        }
    </style>
}
    <body class="page-makerintro page-morebuy">
        <div class="mescroll" id="mescroll">

            <div class="morebuy">
                <span class="rule" id="rule">活动规则</span>
                <div class="over fn28">
                    距离活动结束<div class="time fn30">
                        <span id="_d0">0</span><span id="_d1">0</span><em class="fn24">:</em><span id="_h0">0</span> <span id="_h1">0</span><em>:</em>
                        <span id="_m0">0</span><span id="_m1">0</span><em>:</em>
                        <span id="_s0">0</span> <span id="_s1">0</span>
                    </div>
                </div>
                <div class="morebuylist">
                    <ul class="masonry" id="dataList"></ul>
                </div>
                <a class="return_top" href="#">返回顶部</a>
            </div>
        </div>

        <a class="goTop">
            <img src="~/Content/css/tokenmall/img/icon/goTop.png" />
        </a>

        <!-- 活动规则弹窗 -->
        <div class="mask"></div>
        <div class="activity_modal" id="activity_modal">
            <div class="content">
                <div class="title"></div>
                <div class="rulesbg">
                    <div class="rules">规则说明</div>
                    <div class="activity_rules">
                        <div class="msg">
                            <h2>活动时间</h2>
                            <p>开始时间：@Model.begin_time.ToString("D")</p>
                            <p>结束时间：@Model.end_time.ToString("D")</p>
                        </div>
                        <div class="msg msg2">
                            <h2>活动规则</h2>
                            @Html.Raw(Model.detail)
                        </div>
                    </div>
                </div>
                <div class="close" id="close"></div>
            </div>
        </div>
        <script type="text/javascript">
        function checkTime(i) {
            if (i < 10) {
                i = '0' + i;
            }
            return i;
        }
        function countTime() {
            //获取当前时间
            var date = new Date();
            var now = date.getTime();
            //设置截止时间
            var str = '@Model.end_time.ToString("yyyy/MM/dd HH:mm:ss")';
            var endDate = new Date(str);
            var end = endDate.getTime();
            //时间差
            var leftTime = end - now;
            //定义变量 d,h,m,s保存倒计时的时间
            var d, h, m, s;
            if (leftTime >= 0) {
                d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
                h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
                //h += d * 24;
                m = Math.floor(leftTime / 1000 / 60 % 60);
                s = Math.floor(leftTime / 1000 % 60);
            }
            if (now > end) {
                d = "00";
                h = "00";
                m = "00";
                s = "00";
                window.location.reload();
                return;
            }
            d = checkTime(d);
            h = checkTime(h);
            m = checkTime(m);
            s = checkTime(s);
            h = String(h).split('');
            m = String(m).split('');
            s = String(s).split('');
            document.getElementById("_d0").innerHTML = d[0];
            document.getElementById("_d1").innerHTML = d[1];
            document.getElementById("_h0").innerHTML = h[0];
            document.getElementById("_h1").innerHTML = h[1];
            document.getElementById("_m0").innerHTML = m[0];
            document.getElementById("_m1").innerHTML = m[1];
            document.getElementById("_s0").innerHTML = s[0];
            document.getElementById("_s1").innerHTML = s[1];
            setTimeout(countTime, 1000);
        }
        $(function () {
            countTime();
            $("#rule").click(function (event) {
                $(".mask").css("display", "block");
                $("#activity_modal").addClass('activity_modal_animation')
            });
            $("#close").click(function (event) {
                $(".mask").css("display", "none");
                $("#activity_modal").removeClass('activity_modal_animation')
            });
        })
        </script>
        <script src="~/Scripts/mescroll/mescroll.min.js"></script>
        <script type="text/javascript">
        $(function () {
            var $container = $('.masonry');
            var status = 1;
            var product_name = "";
            var total_pages = 1;
            var isload = false;
            let dataUrl = '/ProductActivity/_ProductTimeBuyList';
            var mescroll = new MeScroll("mescroll", {
                down: {
                    auto: false,
                    callback: function (mescroll) {
                        mescroll.resetUpScroll();
                    }
                },
                up: {
                    callback: askData,
                    page: { num: 0, size: 6 },
                    clearEmptyId: "dataList",
                    isBounce: false,
                    noMoreSize: 3,
                    htmlNodata: '<p class="upwarp-nodata">亲,我是有底线的~</p >',
                    empty: { warpId: "dataList", icon: "", tip: "亲,暂时没有数据哦~" },
                    toTop: {}
                }
            });
            //异步请求数据
            function askData(pager) {
                if (!isload && total_pages >= pager.num) {
                    isload = true;
                    $.ajax({
                        type: "post",
                        url: dataUrl,
                        params: "contentType",
                        data: { page: pager.num, size: pager.size, activityId: '@Model.id' },
                        async: true,
                        success: function (res) {
                            var $elems = $(res);
                            var paged = $elems.siblings("page");
                            var rows = Number.parseInt(paged.attr("rows"));
                            var total = Number.parseInt(paged.attr("total_result"));
                            mescroll.endBySize(rows, total);
                            if (paged.length == 1) {
                                total_pages = Number.parseInt(paged.attr("total_pages"));
                                $container.append($elems);
                                $('#dataList page').remove();
                            }
                            isload = false;
                        },
                        error: function (err) {
                            isload = false;
                            mescroll.endErr();
                        }
                    });
                }
            }
        })
        </script>
    </body>

